<?php
namespace Trawind\NetSuite\Repository\Finance\Setup;

use Trawind\NetSuite\PHPToolkit\AddRequest;
use Trawind\NetSuite\PHPToolkit\UpdateRequest;
use Trawind\NetSuite\PHPToolkit\RecordRef;
use Trawind\NetSuite\PHPToolkit\CustomListSearchBasic;
use Trawind\NetSuite\PHPToolkit\InventoryItem;
use Trawind\NetSuite\Repository\Common;

class Term extends Common
{
    public $service;

    public $type = 'customList';

    public $pageSize = 1000;

    public $search = CustomListSearchBasic::class;

    public $searchFields = ['valueId', 'value'];

    public $id = 69;

    public function __construct($config=null)
    {
        parent::__construct($config);
    }

    /**
     * @return mixed
     * @throws \Exception
     */
    public function getTermList()
    {
        $terms = $this->show($this->id);
        $data = [];
        $index = 0;
        foreach ($terms->customValueList->customValue as $value) {
            foreach ($this->searchFields as $searchField) {
                $data[$index][$searchField] = $value->$searchField;
            }
            $index++;
        }
        return $data;
    }
}


